package pt.nmfa.peste.session;

import pt.nmfa.peste.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("actionParametersHome")
public class ActionParametersHome extends EntityHome<ActionParameters> {

	@In(create = true)
	DeviceActionsHome deviceActionsHome;

	public void setActionParametersActionParametersId(Integer id) {
		setId(id);
	}

	public Integer getActionParametersActionParametersId() {
		return (Integer) getId();
	}

	@Override
	protected ActionParameters createInstance() {
		ActionParameters actionParameters = new ActionParameters();
		return actionParameters;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		DeviceActions deviceActions = deviceActionsHome.getDefinedInstance();
		if (deviceActions != null) {
			getInstance().setDeviceActions(deviceActions);
		}
	}

	public boolean isWired() {
		if (getInstance().getDeviceActions() == null)
			return false;
		return true;
	}

	public ActionParameters getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
